package com.xigua._a04_bean的后处理器;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2022/4/121:16
 */
@Slf4j
@Component
public class Bean1 {

    private Bean2 bean2;

    private Bean3 bean3;

    private String home;


    public Bean1() {
        log.debug("bean1实例化");
    }

    @Resource
    public void setBean3(Bean3 bean3){
        log.info("autowired注解解析成功");
        this.bean3 = bean3;
    }

    @Autowired
    public void getJavaHome(@Value("#${JAVA_HOME}")String home){
        log.info("value注解解析成功:"+home);
        this.home = home;
    }

    @Autowired
    public void setBean2(Bean2 bean2){
        log.info("resoutce注解解析成功");
        this.bean2 = bean2;
    }


    @PostConstruct
    public void inti(){
        log.debug("bean初始化前执行");
    }

    @PreDestroy
    public void destroy(){
        log.debug("bean销毁前执行");
    }


    @Override
    public String toString() {
        return "Bean1{" +
                "bean2=" + bean2 +
                ", bean3=" + bean3 +
                ", home='" + home + '\'' +
                '}';
    }
}
